package com.webside.rtypemapping.service.impl;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webside.rtypemapping.mapper.RTypeMappingMapper;
import com.webside.rtypemapping.model.RTypeMapping;
import com.webside.rtypemapping.service.RTypeMappingService;
import com.webside.subject.model.SubjectEntity;

@Service("rTypeMappingService")
public class RTypeMappingServiceImpl implements RTypeMappingService{

	@Autowired
	RTypeMappingMapper rTypeMappingMapper;
	
	public int insertRTypeMapping(RTypeMapping rTypeMapping) {
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");// 可以方便地修改日期格式
		String nowTime = dateFormat.format(now);
		ParsePosition pos = new ParsePosition(0);
		 Date currentTime_2 = dateFormat.parse(nowTime, pos);
		rTypeMapping.setCreateTime(currentTime_2);
		
		return rTypeMappingMapper.insertRTypeMapping(rTypeMapping);
	}

	public int deleteRTypeMappingById(Integer id) {

		return rTypeMappingMapper.deleteRTypeMappingById(id);
	}

	public int deleteRTypeMappingBySourceTypeName(String sourceTypeName) {

		return rTypeMappingMapper.deleteRTypeMappingBySourceTypeName(sourceTypeName);
	}

	public int updateRTypeMappingByCondition(Map<String, Object> map) {

		return rTypeMappingMapper.updateRTypeMappingByCondition(map);
	}

	public List<RTypeMapping> selectRTypeMappingByCondition(Map<String, Object> map) {

		return rTypeMappingMapper.selectRTypeMappingByCondition(map);
	}

	@Override
	public List<RTypeMapping> queryListByPage(Map<String, Object> parameters) {
		
		return rTypeMappingMapper.queryListByPage(parameters);
	}

	@Override
	public int updateRTypeMapping(RTypeMapping retype) {
		rTypeMappingMapper.updateRTypeMapping(retype);
		int tag =0;
		if(rTypeMappingMapper.selectRTypeMapping(retype)!=null){
			tag = 1;
		}
		return tag;
	}

	@Override
	public int deleteBatchById(List<Long> list) {
		
		return rTypeMappingMapper.deleteBatchById(list);
	}
	
}
